<!DOCTYPE html>
<#assign dicSelect=JspTaglibs["http://www.casic304.cn/dicSelect"] />
<#assign secSelect=JspTaglibs["http://www.casic304.cn/secSelect"] />
<#assign fillDept=JspTaglibs["http://www.casic304.cn/fillDept"] />
<html>
<head>
    <meta charset="utf-8">
    <title>QC成果基本信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/forms/currencyCss.css">
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
    <style>
        .qbdms-TBinformation {
            margin-left: 0;
            font-size: 15px
        }

        .qbdms-TBinformationText {
            margin-left: 145px;
        }
    </style>
</head>
<body class="listBody">
<div class="qbdms-bodyDiv">
    <div class="qbdms-backDiv">
        <div class="layui-table-view-body" style="padding: 0 24px 24px;">
            <div class="qbdms-formTitle" style="border-bottom: 1px solid #E5F0FF">QC成果<i class="qbdms-returnOn closeWindow" id="back">返回</i></div>
            <form class="layui-form treeFormPreview" requrl="${ctx}/qbdms/wQbdQcAchievement/get" lay-filter="wQbdQcAchievementDataForm" id="wQbdQcAchievementDataForm">
                <@fillDept.dept id="tbxx"/>
                <div class="layui-row">
                    <div style="width: 65%">
                        <label class="layui-form-label qbdms-label" title="密级">密级<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <@secSelect.sec_select data_src=1 required=true name="secret"/>
                        </div>
                    </div>
                    <div style="width: 65%">
                        <label class="layui-form-label qbdms-label" title="QC小组名称">QC小组名称<span style="color: red;">*</span></label>
                        <button type="button" class="layui-btn qbdms-twoBtn" id="selectGroupnameBtn" style="float: right">选择</button>
                        <div class="layui-input-block qbdms-input qbdms-inputIsButton">
                            <input type="text" placeholder="请选择" autocomplete="off" class="layui-input textInput" lay-verify="required" lay-reqtext="QC小组名称是必填项" name="qcGroupName" maxlength="50" readonly>
                        </div>
                    </div>
                    <div style="width: 65%">
                        <label class="layui-form-label qbdms-label" title="注册编号">注册编号<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" name="registrationNumber" placeholder="自动计算" autocomplete="off" class="layui-input  textInput isReadonlyInput" lay-verify="required" lay-reqtext="注册编号是必填项" maxlength="50" readonly>
                        </div>
                    </div>
                    <div style="width: 65%">
                        <label class="layui-form-label qbdms-label" title="注册时间">注册时间<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" name="registrationDate" placeholder="自动计算" lay-reqtext="注册时间是必填项" autocomplete="off" class="layui-input dateTimeFiled textInput time-init isReadonlyInput" lay-verify="required" maxlength="50" disabled>
                        </div>
                    </div>
                    <div style="width: 65%">
                        <label class="layui-form-label qbdms-label" title="注册单位">注册单位<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" name="registrationUnit" placeholder="自动计算" autocomplete="off" class="layui-input isReadonlyInput" lay-verify="required" lay-reqtext="注册单位是必填项" maxlength="50" readonly>
                        </div>
                    </div>
                    <div style="width: 65%">
                        <label class="layui-form-label qbdms-label" title="成果名称">成果名称<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" name="achievementName" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="required" lay-reqtext="成果名称是必填项" maxlength="50">
                        </div>
                    </div>
                    <div style="width: 65%">
                        <label class="layui-form-label qbdms-label" title="评定时间">评定时间<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" name="evaluationTime" placeholder="请选择" autocomplete="off" class="layui-input dateTimeFiled input-right time-init" maxlength="50" lay-verify="required" lay-reqtext="评定时间是必填项" readonly>
                        </div>
                    </div>
                    <div style="width: 65%">
                        <label class="layui-form-label qbdms-label" title="获奖等级">获奖等级</label>
                        <div class="layui-input-block qbdms-input">
                            <@dicSelect.dic name="awardLevel" nodeKey="hjdj" />
                        </div>
                    </div>
                    <div style="width: 65%">
                        <label class="layui-form-label qbdms-label" title="报告文件名">报告文件名</label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" name="nameOfReportFile" placeholder="请输入" autocomplete="off" class="layui-input" maxlength="50">
                        </div>
                    </div>
                    <div style="width: 76%">
                        <label class="layui-form-label qbdms-label" title="报告文件上传">报告文件上传</label>
                        <div class="layui-input-block qbdms-input">
                            <input type="button" class="layui-btn iconfont iconupload fileUpload qbdms-fileUp" value="上传附件"/>
                            <i class="qbdms-fileUpText">支持单个附件上传，附件格式：doc docx pdf，文件大小限制不超过100M</i>
                            <input type="text" id="reportFile" class="uploadInput" name="reportFile" style="display: none">
                            <div class="uploadFileList" fileUploadName="reportFile" style="padding-top: 9px;"></div>
                        </div>
                    </div>
                    <div style="width: 76%">
                        <label class="layui-form-label qbdms-label" title="备注">备注</label>
                        <div class="layui-input-block qbdms-input">
                            <textarea type="text" name="remark" placeholder="请输入" autocomplete="off" class="layui-input" maxlength="50" style="min-height:64px;padding-top: 5px"></textarea>
                        </div>
                    </div>
                    <#if flag =="1">
                    <div class="qbdms-textarea  ">
                        <label class="layui-form-label qbdms-label">质量综合助理员确定</label>
                        <div class="layui-input-block qbdms-input">
                            <#list taskOpinionNewList as taskOpinionNewList>
                            <#if taskOpinionNewList.taskName == "质量综合助理员确定">
                            <p>${taskOpinionNewList.opinion}</p><br/>
                            <p style="text-align:right;">审批人:${taskOpinionNewList.exeFullname}&nbsp&nbsp&nbsp&nbsp
                            日期:${(taskOpinionNewList.endTime?string("yyyy-MM-dd"))!}</p>
                                </#if>
                            </#list>
                        </div>
                    </div>
                    </#if>
                </div>
                <div class="layui-hide">
                    <input type="text" name="id" placeholder="请输入" autocomplete="off" class="layui-input  textInput" maxlength="50" fieldname="id">
                    <input type="text" name="registrationUnitCode" placeholder="请输入" autocomplete="off" class="layui-input  textInput" maxlength="50" fieldname="registrationUnitCode">
                </div>
                <div class="layui-form-item btnformItem">
                    <p style="text-align: left;padding-left: 246px">
                    <span id="hideAndShow" style="display: none;">
                        <a lay-submit lay-filter="wQbdQcAchievement" class="layui-btn btn-n privateSubmit qbdms-oneBtn" requrl="${ctx}/qbdms/wQbdQcAchievement/save" id="urlFormSave">保存</a>
                        <a lay-filter="wProblemresetMsg" id="run" class="layui-btn btn-n qbdms-oneBtn">启动</a>
                        <button type="reset" id="closeWindow" style="margin-left: 10px;" class="layui-btn layui-btn-sm qbdms-oneBtnLine closeWindow">取消</button>
                    </span>
                    </p>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    var vaildFlag ;
    var runFlag=false;
    var flowStatus="${flowStatus}";
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'setter', 'qbdmsForm', 'layer', 'upload', 'common', 'propsHandle', 'jquery', 'publicMethods', 'commonDialog'], function () {
        var laydate = layui.laydate;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var upload = layui.upload;
        var setter = layui.setter;
        var form = layui.qbdmsForm;
        var commonDialog = layui.commonDialog;
        var propsHandle = layui.propsHandle;
        var defProps = {
                //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle();  // 实例化模板功能部分
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });
        var dateTimeFiledLen = $(".dateTimeFiled");
        for (var i = 0; i < dateTimeFiledLen.length; i++) {
            laydate.render({
                elem: dateTimeFiledLen[i] //指定元素
                , type: 'date'
                , trigger: 'click'
            });
        }

        vaildFlag = false;
        $("#urlFormSave").click(function () {
            var selectMaxVal = 0;
            var formSecretVal = $("[name='secret']").val();
            $(".fileSecLevel select").each(function () {
                selectMaxVal = selectMaxVal >= $(this).val() ? selectMaxVal : $(this).val();
            });

            if (selectMaxVal > formSecretVal) {
                layer.msg('附件密级不能高于表单密级。', {icon: 5});
                vaildFlag = false;
                return false;
            }
            vaildFlag=form.VerifyForm("wQbdQcAchievementDataForm");
        });

        //关闭当前页面
        $("#closeWindow,.closeWindow").click(function () {
            window.location.href = '${ctx}/qbdms/wQbdQcAchievement/view/list';
        });

        //下载附件
        window.downFile = function (obj) {
            var fileId = $(obj).parents("span").attr("fileId");
            window.location.href = serverPath.qbdmsPath + setter.extendLinkPath + "attachFile/download?fileId=" + fileId;
        }
        // 删除
        $(document).on('click', '.deleteFile', function () {
            $(this).parent().parent().siblings("button").show()
            $(this).parent().remove();
            $(".uploadFileList").each(function (i, v) {
                common.constructFileStr(v)
            });
        });

        if(flowStatus == null || flowStatus == 0|| flowStatus==99){
            $("#hideAndShow").show();
        }else{
            $("#back").hide();
        }
        if(flowStatus==99){
            $("#run").hide();
        }
        var secSelect = '<@secSelect.sec_select data_src=1 hasBlank=false/>'
        common.uploadfun(".fileUpload", {
            acceptMime: 'application/pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document',
            exts: "doc|docx|pdf",
            secSelect: secSelect,
            isSub: false,
            upLoadSize: 102400,
            upLoadNumber: 1,
            isMultiFile: false
        });
        common.updateForm({
            name: 'wQbdQcAchievementDataForm',
            idValue: "${id}",
            primary: "id",
            beforeSubmitFun: function (data) {
                //- 附件密级不能高于表单密级 开始 ------------------------------------------------------
                var selectMaxVal = 0;
                var formSecretVal = $("[name='secret']").val();
                $(".fileSecLevel select").each(function () {
                    selectMaxVal = selectMaxVal >= $(this).val() ? selectMaxVal : $(this).val();
                });

                if (selectMaxVal > formSecretVal) {
                    layer.msg('附件密级不能高于表单密级。', {icon: 5});
                    return false;
                }
                //- 附件密级不能高于表单密级 结束 ------------------------------------------------------
                $(".uploadFileList").each(function (i, v) {
                    common.constructFileStr(v)
                });
                var files=[];
                //整理上传附件的隐藏域，将提交的字符串转为json对象
                $(".uploadInput").each(function () {
                    var uploadName = $(this).attr("name");
                    if (!$(this).val()) {
                        return;
                    }
                    data.field[uploadName] = eval($(this).val());
                    files=files.concat(eval($(this).val()));
                });

                return common.setFileLevel(files);

            },
            getCallback: function (data) {
                $("#tbxx").html("<span class='qbdms-TBinformation'>填报信息:</span><span class='qbdms-TBinformationText'>【" + data.data.filldept + " | " + data.data.fillman + " | " + data.data.filldate + "】</span>");
                //-修改页面 初始化附件组件 开始 ------------------------------------------
                $('.uploadFileList').each(function () {
                    var fileUploadName = $(this).attr("fileUploadName");
                    var jsonFile = data.data[fileUploadName];
                    var files = eval(jsonFile);

                    if (files) {
                        for (var i = 0; i < files.length; i++) {
                            var fileLevel = files[i].fileLevel;
                            var fileLevelText = files[i].fileLevelText;
                            var fileSec = '<div class="fileSecLevel layui-input-inline">' + '<@secSelect.sec_select data_src=1 hasBlank=false/>' + "</div>";
                            var newStr = '<span class="file-id" style="margin-right: 20px;" fileId=' + files[i].fileId + ' fileLevelText="' + fileLevelText + '">' + fileSec + '<span class="file-name" title="点击下载文件" onclick="downFile(this)"><i class="iconfont data-iconcommon_fujian" style="margin-right: 5px"></i>' + files[i].fileName + '</span><i class="iconfont data-iconcommon_close deleteFile" ></i></span>';
                            $(this).html(newStr);
                            $(this).find("select:last").val(fileLevel);
                        }
                    }
                });
                //-修改页面 初始化附件组件 结束 ------------------------------------------
            },
            updateCallback: function (data) {
                if((flowStatus==0||flowStatus==""||null==flowStatus)&&runFlag==true){
                    run(data.data.id);
                }
                if (publicMethods._filterRecord(data)) {
                    if ($(".privateSubmit")) {
                        $(".privateSubmit").attr("disabled", false).css("pointer-events", "auto");
                    }
                    if((flowStatus=="0" || flowStatus==null||flowStatus==""||flowStatus=="99")&&runFlag==false) {
                        layer.alert(publicMethods.confirmStyle(data.msg), {title: false, skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            window.location.href = '${ctx}/qbdms/wQbdQcAchievement/view/list';
                        });
                    }
                } else {
                    if((flowStatus=="0" || flowStatus==null||flowStatus==""||flowStatus=="99")&&runFlag==false) {
                        layer.alert(publicMethods.confirmStyle(data.msg), {title: false, skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            window.location.href = '${ctx}/qbdms/wQbdQcAchievement/view/list';
                        });
                    }
                }
                runFlag=false;
                return false;
            }
        });

        //-- QC小组选择器 开始 --------------------------------------------------------------
        $("#selectGroupnameBtn").click(function () {
            var paramValueString = "";
            commonDialog.CommonDialog("qcxzxzq", function (data, selectIds) {
                var dataObj = JSON.parse(data);
                var groupName = dataObj.GROUPNAME,
                    ids = dataObj.REGISTERNUM,
                    dept = dataObj.REGISTERDEPT,
                    deptId = dataObj.REGISTERDEPTID,
                    date = dataObj.REGISTERDATE.slice(0, 10);
                //对象赋值
                $("input[name='qcGroupName']").val(groupName);
                $("input[name=registrationNumber]").val(ids);
                $("input[name=registrationUnit]").val(dept);
                $("input[name='registrationUnitCode']").val(deptId);
                $("input[name=registrationDate]").val(date);
            }, paramValueString);
        });
        //-- QC小组选择器 结束 --------------------------------------------------------------

        publicMethods.bottomFixd()
        form.on('select', function (data) {
            publicMethods.bottomFixd()
        });
        form.render();

        $("#run").click(function () {
            var flag=form.VerifyForm("wQbdQcAchievementDataForm");
            if(flag==false){
                return false;
            }
            runFlag=true;
            $("#urlFormSave").click();
        })
        function run(id) {
            var id = id;
            var secret = $("input[name='secret']").val();
            var fillman = $("input[name='fillman']").val();
            var fillmanaccount = $("input[name='fillmanaccount']").val();
            var filldept = $("input[name='filldept']").val();
            var filldeptid = $("input[name='filldeptid']").val();
            var reportStatus = $("input[name='reportStatus']").val();
            var returnmsg = $("input[name='returnmsg']").val();
            var filldepthospital = $("input[name='filldepthospital']").val();
            var filldepthospitalid = $("input[name='filldepthospitalid']").val();
            var reportDate = $("input[name='reportDate']").val();
            var tenantId = $("input[name='tenantId']").val();
            var createBy = $("input[name='createBy']").val();
            var createTime = $("input[name='createTime']").val();
            var updateBy = $("input[name='updateBy']").val();
            var updateTime = $("input[name='updateTime']").val();
            var belongdeptname = $("input[name='belongdeptname']").val();
            var reportReason = $("input[name='reportReason']").val();
            var filldate = $("input[name='filldate']").val();
            var qcGroupName = $("input[name='qcGroupName']").val();
            var registrationNumber = $("input[name='registrationNumber']").val();
            var registrationDate = $("input[name='registrationDate']").val();
            var registrationUnit = $("input[name='registrationUnit']").val();
            var registrationUnitCode = $("input[name='registrationUnitCode']").val();
            var evaluationTime = $("input[name='evaluationTime']").val();
            var achievementName = $("input[name='achievementName']").val();
            var awardLevel = $("input[name='awardLevel']").val();
            var nameOfReportFile = $("input[name='nameOfReportFile']").val();
            var reportFile = $("input[name='reportFile']").val();
            var remark = $("input[name='remark']").val();
          var flowStatus = $("input[name='flowStatus']").val();
            var nowData = {"id": id,"secret": secret,"fillman": fillman,"fillmanaccount": fillmanaccount,"filldept": filldept,"filldeptid": filldeptid,"reportStatus": reportStatus,"returnmsg": returnmsg,"filldepthospital": filldepthospital,"filldepthospitalid": filldepthospitalid,"reportDate": reportDate,"tenantId": tenantId,"createBy": createBy,"createTime": createTime,"updateBy": updateBy,"updateTime": updateTime,"belongdeptname": belongdeptname,"reportReason": reportReason,"filldate": filldate,"qcGroupName": qcGroupName,"registrationNumber": registrationNumber,"registrationDate": registrationDate,"registrationUnit": registrationUnit,"registrationUnitCode": registrationUnitCode,"evaluationTime": evaluationTime,"achievementName": achievementName,"awardLevel": awardLevel,"nameOfReportFile": nameOfReportFile,"reportFile": reportFile,"remark": remark,"flowStatus": flowStatus};
            $.ajax({
                url:"${ctx}/qbdms/wQbdQcAchievement/run",
                type: "post",
                dataType: 'json',
                contentType : 'application/json',
                data: JSON.stringify(nowData),
                success : function (data) {
                    if (common.filterRecord(data)) {
                        layer.alert(publicMethods.confirmStyle(data.msg), {title: false, skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            window.location.href = '${ctx}/qbdms/wQbdQcAchievement/view/list';
                        });
                    } else {
                        layer.alert(publicMethods.confirmStyle(data.msg), {title: false, skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            window.location.href = '${ctx}/qbdms/wQbdQcAchievement/view/list';
                        });
                    }
                    return false;
                },
                error : function (XMLHttpRequest, textStatus, errorThrown) {
                    layer.alert(publicMethods.confirmStyle("内容已保存，启动失败"), {title: false, skin: 'confirm-class'}, function (index) {
                        layer.close(index);
                        window.location.href = '${ctx}/qbdms/wQbdQcAchievement/view/list';
                    });
                }
            })
        }
    });
</script>
</body>
</html>